package com.kaifamiao.www.demo.Do20;

public class De01 {

    public static void main(String[] args) {
        //冒泡排序
        double[] scores = new double[5];
        //math.random生成0-1之间的伪随机数
        for(int i = 0;i < scores.length;i++){
            double score = (int)(Math.random()*10000)/100.0;
            scores[i] = score;
        }
        System.out.println("排序前");//输出字符“排序前”
        for(int i = 0;i < scores.length;i++){
            System.out.print(scores[i]+"\t");
        }
        //进行冒泡排序
        for(int i = 1;i < scores.length;i++){
            for(int j = 0;j < scores.length-i;j++){
                if(scores[j] < scores[j+1]){
                    double temp = scores[j+1];
                    scores[j+1] = scores[j];
                    scores[j] = temp;
                }
            }
        }
        System.out.println("\n排序后");
        //遍历输出
        for(int i = 0;i < scores.length;i++){
            System.out.print(scores[i]+"\t");
        }
    }
}
